home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 5.5 KB | 235 lines | [TEXT/ToyS] |
- -- Properties
- property kasPrefName : "Image Icons V1.0"
-
- property kasImgBox : {32, 0, 128, 128} -- Box of image
-
- -- Globals
- global gasInfoWind -- Info window
- global gasInfoPos -- Position of info window
- global gasDrawing -- Draw window
- global gasDrawPos
-
- global gasFoldersToDo -- The folders left to process
- global gasShown -- Number gone!
- global gasChecked -- Number checked!
-
-
- on open fsObjs
- -- Load prefs, show window
- pfLoad()
-
- -- Set up prefix
- set gasShown to 0
- set gasChecked to 0
- set gasShowWind to 0
-
- set gasInfoWind to display info titled kasPrefName ¬
- located at gasInfoPos ¬
- message "Scanning…"
-
- set gasDrawing to ¬
- display drawing titled ("Icon Creation") ¬
- located at gasDrawPos ¬
- with dimensions {128, 128}
-
- -- Do files
- set gasFoldersToDo to {}
-
- repeat with fsObj in fsObjs
- set myInfo to (basic info for fsObj)
-
- if (system type of myInfo is "fold") then
- set gasFoldersToDo to gasFoldersToDo & {fsObj}
- else
- DoOne(fsObj)
- end if
- end repeat
-
- -- Do folders
- repeat while gasFoldersToDo is not {}
- -- Pop one off the end
- set n to the number of items of gasFoldersToDo
- set fsObj to item n of gasFoldersToDo
-
- if (n > 1) then
- set gasFoldersToDo to items 1 through (n - 1) of gasFoldersToDo
- else
- set gasFoldersToDo to {}
- end if
-
- display info gasInfoWind ¬
- message ("Folders to go: " & n) ¬
- at line 6 ¬
- using color (15 * 32)
-
- -- Process it
- GoDeep(fsObj)
- end repeat
-
- display info gasInfoWind message "DONE!"
-
- pause for 2 with seconds timing -- Let screen wait...
-
- beep
-
- set gasInfoPos to screen location of ¬
- (display info gasInfoWind with disposal)
-
- beep
-
- set gasDrawPos to screen location of ¬
- (display info gasDrawing with disposal)
-
- beep
-
- pfSave() -- Save window location
- end open
-
-
- on DoOne(fsObj)
- set imageType to the image type in fsObj
- set fname to (catalog name of (basic info for fsObj))
-
- display info gasInfoWind ¬
- message fname ¬
- at line 2
-
- if (imageType is not "") then
- display info gasInfoWind ¬
- message imageType ¬
- at line 3
- -- Get picture
- set imagePic to the image from fsObj
- -- Get its bounds
- set pBox to picture bounds of (the picture info for imagePic)
- -- Center it
- set drawInto to PlaceInCenter(pBox, kasImgBox)
- -- Image BG
- draw a box into gasDrawing ¬
- inside of kasImgBox ¬
- filling it with the pen ¬
- using state {fg color:"EEEEEE"} ¬
- with a clear slate
- -- Draw image
- -- draw a picture into gasDrawing ¬
- -- inside of drawInto ¬
- -- using data imagePic
- -- Free image
- set imagePic to 0
- -- Draw Ear-lap
- draw a box into gasDrawing ¬
- inside of {96, 0, 128, 32} ¬
- filling it by erasing it
- draw a polygon into gasDrawing ¬
- using data {{96, 0}, {96, 32}, {128, 32}} ¬
- filling it with the pen ¬
- using state {fg color:"CCCCCC", pen size:{3, 3}}
- draw a polygon into gasDrawing ¬
- using data {{96, 36}, {128, 36}} ¬
- using state {fg color:"EEEEEE"}
- draw a polygon into gasDrawing ¬
- using data {{96, 0}, {96, 32}, {128, 32}} ¬
- using state {fg color:"000000"}
- -- Frame the image
- draw a polygon into gasDrawing ¬
- using data {{32, 0}, {96, 0}, {125, 32}, {125, 125}, {32, 125}, {32, 0}}
- -- Draw text
- draw a text box into gasDrawing ¬
- inside of {4, 6, 34, 128} ¬
- using data ("A" & return & "K" & return & "U" & return & "A") ¬
- using state {text font:"Chicago", text size:24, text face:1, fg color:"5599FF"}
- draw a text box into gasDrawing ¬
- inside of {0, 2, 30, 124} ¬
- using data ("A" & return & "K" & return & "U" & return & "A") ¬
- using state {fg color:"224488"}
- draw a text box into gasDrawing ¬
- inside of {2, 4, 32, 126} ¬
- using data ("A" & return & "K" & return & "U" & return & "A") ¬
- with refresh
- -- Get Picture / Assign Icon
- set the icon of fsObj to (capture picture from gasDrawing with pixel conversion)
- -- clip (capture picture from gasDrawing)
- else
- display info gasInfoWind ¬
- message ¬
- "Unknown" at line 3
- end if
- end DoOne
-
-
- on GoDeep(foldObj)
- display info gasInfoWind ¬
- message "Path: " & (foldObj as string)
-
- set daddy to foldObj as string
-
- -- Do kinds that match
- display info gasInfoWind ¬
- message "Scanning files" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a file
-
- repeat with myItem in myItems
- DoOne((daddy & myItem) as alias)
- end repeat
-
- -- Do folders
- display info gasInfoWind ¬
- message "Scanning subfolders" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a folder
-
- repeat with myItem in myItems
- set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
- end repeat
-
- -- Done
- display info gasInfoWind ¬
- message "…" at line 5
- end GoDeep
-
-
- on PlaceInCenter(src, dst)
- set sW to (item 3 of src) - (item 1 of src)
- set sH to (item 4 of src) - (item 2 of src)
- set dW to (item 3 of dst) - (item 1 of dst)
- set dH to (item 4 of dst) - (item 2 of dst)
-
- set r to dW / sW
- set rH to dH / sH -- ratios
-
- if (rH < r) then set r to rH
-
- -- Round to a .25 ratio if > 1
- if (r > 1) then ¬
- set r to 0.25 * (round (r * 4))
-
- -- Scale the src
- set sW to round (sW * r)
- set sH to round (sH * r)
- set mW to round ((dW - sW) / 2) + (item 1 of dst)
- set mH to round ((dH - sH) / 2) + (item 2 of dst)
-
- -- Center it
- return {mW, mH, mW + sW, mH + sH}
- end PlaceInCenter
-
-
- on pfLoad()
- try
- set ourPrefs to (load preference named kasPrefName)
- on error
- set ourPrefs to {{8, 48}, {8, 112}}
- end try
-
- set gasInfoPos to item 1 of ourPrefs
- set gasDrawPos to item 2 of ourPrefs
- end pfLoad
-
-
- on pfSave()
- save preference {gasInfoPos, gasDrawPos} named kasPrefName
- end pfSave
-